#include <bits/stdc++.h>

#define in read()

using namespace std;

typedef long long ll;

ll read(){ll x = 0,sgn = 1;char ch = getchar();for(;!isdigit(ch);ch = getchar()) if(ch == '-') sgn = -1;for(;isdigit(ch);ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ 48); return x * sgn;}

const int N = 3e5+10;

int n,s,b[2],c[N],d[N];
ll ans,a[N];

void calc(int x){int mx = d[x]; for(int i = x - 1;i >= (x - 64) && i >= 0;i--,mx = max(mx,d[i+1])) if((c[i] & 1) == (c[x] & 1) && mx * 2 > (c[x] - c[i])) ans--;}

int popcount(ll x){int res = 0;for(;x;x >>= 1) res += x & 1; return res;}

int main(){
	n = in; b[0] = 1;for(int i = 1;i <= n;i++) a[i] = in,s += (d[i] = popcount(a[i])),c[i] = s,ans += b[s & 1],b[s & 1]++,calc(i); printf("%lld\n",ans);
	return 0;
}
